import js from "@eslint/js"
import globals from "globals"
import tseslint from "typescript-eslint"
import pluginVue from "eslint-plugin-vue"
import prettierRecommended from "eslint-plugin-prettier/recommended"
import { defineConfig } from "eslint/config"
// 第一种
// import autoImport from "./.eslintrc-auto-import.json" with {type:"json"}
// 第二种
import {createRequire} from "module"
const require=createRequire(import.meta.url)
const autoImport=require("./.eslintrc-auto-import.json")
// 第三种 fs.readFile

export default defineConfig([
  {
    files: ["**/*.{js,mjs,cjs,ts,mts,cts,vue}"],
    plugins: { js },
    extends: ["js/recommended"],
  },
  {
    files: ["**/*.{js,mjs,cjs,ts,mts,cts,vue}"],
    languageOptions: { globals: { ...globals.browser, ...globals.node,...autoImport.globals} },
  },
  tseslint.configs.recommended,
  pluginVue.configs["flat/essential"],
  {
    files: ["**/*.vue"], //校验vue中的ts代码
    languageOptions: { parserOptions: { parser: tseslint.parser } },
  },
  {
    // 哪些文件不通过eslint来进行校验
    ignores: [".css", "*.d.ts"],
  },
  {
    // 自定义规则，根据需要增加，eslint主要校验代码规范  prettier
    rules: {
      // "no-console": "warn",
      // semi: ["error"],
    },
  },
  prettierRecommended, //覆盖掉eslint的规范
])
